/**
 * Copyright 2011 Poltman.Ltd; www.poltman.com. All rights reserved.		
 *
 * This file is part of the dspace-poltman project http://www.poltman.com.
 *
 * This is free software; you can redistribute it and/or modify it under
 * the terms of DuraSpace DSpace license detailed in the LICENSE and NOTICE 
 * files at the root of the source tree and available online at
 * http://www.dspace.org/license/
 * 
 */

package com.poltman.dscentral.db.service.dspace.impl;


import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.poltman.dscentral.db.entity.dspace.HandleEntity;
import com.poltman.dscentral.db.exceptions.RepositoryAccessException;
import com.poltman.dscentral.db.exceptions.RepositoryException;
import com.poltman.dscentral.db.repository.dspace.HandleRepository;
import com.poltman.dscentral.db.service.dspace.HandleService;




/**
 * 
 * @author z.ciok@poltman.com
 * @version $Revision: 1515 $
 *
 */
@Repository
@Service("handleService")
public class HandleServiceImpl implements HandleService {
	
	private static Logger log = Logger.getLogger(HandleServiceImpl.class);
	
	@Autowired
	private HandleRepository handleRepository;
	
	@Override
	public HandleEntity findByResourceTypeIdAndResourceId(Integer resourceTypeId, Integer resourceId) throws RepositoryAccessException, RepositoryException {
		return handleRepository.findByResourceTypeIdAndResourceId(resourceTypeId, resourceId);
	}
	
	@Transactional
	@Override
	public HandleEntity save(HandleEntity handleEntity)  throws RepositoryAccessException, RepositoryException {
		return handleRepository.save(handleEntity);
	}
	
	@Transactional
	@Override
	public int setFixedHandleFor(String handle, Integer handleId) throws RepositoryAccessException, RepositoryException {
		return handleRepository.setFixedHandleFor(handle, handleId);
	}
}